class Solution {
public:
    bool increasingTriplet(vector<int>& nums) {
        int first = INT_MAX;
        int second = INT_MAX;

        for(int& num : nums)
        {
            if(num <= first)
            {
                first = num;
            }
            else if(num <= second)
            {
                second = num;
            }
            else
            {
                return true;
            }
        }

        return false;
    }
};

class Solution {
public:
    int findLengthOfLCIS(vector<int>& nums) {
        int ret = 1;
        int left = 0;
        int right = 0;

        while(right < nums.size())
        {
            if(right-1 < 0)
            {
                right++;
                continue;
            }

            if(nums[right] <= nums[right-1])
            {
                ret = max(ret,right-left);
                left = right;
            }a

            right++;
            if(right == nums.size())
                ret = max(ret,right-left);
        }

        return ret;
    }
};

class Solution {
public:
    int longestPalindrome(string s) {
        int uprcount[26] = {0};
        int lowcount[26] = {0};

        for(char ch : s)
        {
            if(isupper(ch))
            {
                uprcount[ch-'A']++;
            }
            else
            {
                lowcount[ch-'a']++;
            }
        }

        int ret = 0;
        int flag = false;
        for(int i = 0; i < 26; ++i)
        {
            if(uprcount[i] % 2 == 0)
            {
                ret += uprcount[i];
            }
            else
            {
                ret += (uprcount[i]-1);
                flag = true;
            }
            if(lowcount[i] % 2 == 0)
            {
                ret += lowcount[i];
            }
            else
            {
                ret += (lowcount[i]-1);
                flag = true;
            }
        }

        if(flag)
        {
            ret += 1;
        }

        return ret;
    }
};

class Solution {
public:
    vector<int> diStringMatch(string s) {
        int left = 0;
        int right = s.size();
        vector<int> result;

        for(char ch : s)
        {
            if(ch == 'I')
            {
                result.push_back(left);
                left++;
            }
            else
            {
                result.push_back(right);
                right--;
            }
        }

        result.push_back(left);

        return result;
    }
};


class Solution {
public:
    string optimalDivision(vector<int>& nums) {
        string ret = to_string(nums[0]);
        if(nums.size() == 2)
        {
            ret += "/"+to_string(nums[1]);
            return ret;
        }

        for(int i = 1; i < nums.size(); ++i)
        {
            if(i == 1)
            {
                ret += "/("+to_string(nums[i]);
            }
            else if(i == nums.size()-1)
            {
                ret += "/"+to_string(nums[i])+")";
            }
            else
            {
                ret += "/"+to_string(nums[i]);
            }
        }

        return ret;
    }
};
